package com.yun.algorithmproblem.leetcode;

import java.util.HashSet;

public class Leetcode2255 {

	public static void main(String[] args) {
		Leetcode2255 obj = new Leetcode2255();
		System.out.println(obj.countPrefixes(new String[]{"a","b","c","ab","bc","abc"}, "abc"));
	}

	public int countPrefixes(String[] words, String s) {
		int ans=0;
		HashSet<String> set = new HashSet<>();
		for (int i = 0; i < s.length(); i++) {
			set.add(s.substring(0, i+1));
		}
		for (String word : words) {
			if(set.contains(word)){
				ans++;
			}
		}
		return ans;
	}
}
